package org.adit.spring.hibernate.infra;

import java.io.IOException;
import java.io.OutputStream;

import javax.servlet.ServletOutputStream;

public class CacheResponseOutputStream extends ServletOutputStream {
	protected boolean closed = false;
    protected ServletOutputStream output = null;
    protected OutputStream cache = null;

    public CacheResponseOutputStream(OutputStream paramOutputStream) throws IOException {
        this.cache = paramOutputStream;
    }

    public void close()
            throws IOException {
        if (this.closed)
            throw new IOException("This output stream has already been closed");
        this.cache.close();
        this.closed = true;
    }

    public void flush()
            throws IOException {
        if (this.closed)
            throw new IOException("Cannot flush a closed output stream");
        this.cache.flush();
    }

    public void write(int paramInt)
            throws IOException {
        if (this.closed)
            throw new IOException("Cannot write to a closed output stream");
        this.cache.write((byte) paramInt);
    }

    public void write(byte[] paramArrayOfByte)
            throws IOException {
        write(paramArrayOfByte, 0, paramArrayOfByte.length);
    }

    public void write(byte[] paramArrayOfByte, int paramInt1, int paramInt2)
            throws IOException {
        if (this.closed)
            throw new IOException("Cannot write to a closed output stream");
        this.cache.write(paramArrayOfByte, paramInt1, paramInt2);
    }

    public boolean closed() {
        return this.closed;
    }

    public void reset() {
    }
}
